package enums;

/**
 * @author lnunno
 *
 */
public class AlphabetRunner {
	public enum Alphabet{
		A, 
		B, 
		C, 
		D, 
		E, 
		F, 
		G;
		
		public Alphabet getNext(){
			return this.ordinal() < Alphabet.values().length-1 
			  ? Alphabet.values()[this.ordinal()+1]
			  : null; 
		}
	}
	
	public void run(){
        Alphabet curLetter = Alphabet.A;
		for(Alphabet a : Alphabet.values()){ //Show what an enum's toString() looks like.
			System.out.println(a);
		}
		for(Alphabet letter : Alphabet.values()){ //Show values of an enum.
			System.out.println("Letter: " + letter +
					" Value = " + letter.ordinal());
		}
		int enumLength = Alphabet.values().length;
		for(int i = 0; i < enumLength; i++){
			System.out.println("Iteration # " + i);
			//Trying to change a value of an enum.
			System.out.println(curLetter);
			curLetter = curLetter.getNext();
		}
	}
	
	public static void main(String[] args) {
		AlphabetRunner runner = new AlphabetRunner();
		runner.run();
	}

}
